import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'common_web_page.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    print("aaaa");
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("webview"),
          ),
          body: HomePage()),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Center(
      child: RaisedButton(
        child: Text("web view flutter"),
        onPressed: () {
          _webView();
        },
      ),
    );
  }

  void _webView() {
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => CommonWebPage(
                  url: "https://www.baidu.com",
                  title: "web",
                )));
  }
}
